package br.edu.unilasalle.simon_test.venda;

import org.joda.time.DateTime;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import br.edu.unilasalle.simon_test.AbstractPage;

public class ListagemVendaPage extends AbstractPage {
	
	@FindBy(id = "dataIni")
	protected WebElement dataIni;
	
	@FindBy(id = "dataFim")
	protected WebElement dataFim;
	
	@FindBy(id = "btnPesquisar")
	protected WebElement btnPesquisar;
	
	public ListagemVendaPage(WebDriver driver) {
		super(driver);
	}
	
	public void abreTela() {
		openAsAdmin();
		open("/#/vendas-list");
	}
	
	public void pesquisar() throws Exception {
		DateTime date = new DateTime();
		typeDate(dataIni, date.minusDays(30));
		typeDate(dataFim, date);
		btnPesquisar.click();
		waitAjaxComplete();
	}

}
